import { useI18n } from '/@/hooks/web/useI18n';
import { FormSchema, FormProps } from '/@/components/Form';
import { choiceFieldApi } from '/@/api/sys/choice';

const { t } = useI18n();

function getFormSchemas(): FormSchema[] {
  return [
    {
      field: 'name',
      label: t('views.patient.name'),
      component: 'Input',
      colProps: {
        span: 12,
      },
    },
    {
      field: 'gender',
      label: t('views.patient.gender'),
      component: 'ApiSelect',
      componentProps: {
        api: () => choiceFieldApi.list('console', 'patient', 'gender'),
        labelField: 'name',
      },
      colProps: {
        span: 12,
      },
    },
    {
      field: 'age',
      label: t('views.patient.age'),
      component: 'Input',
      colProps: {
        span: 12,
      },
    },
    {
      field: 'phone',
      label: t('views.patient.phone'),
      component: 'Input',
      colProps: {
        span: 12,
      },
    },
    {
      field: 'clinical_diagnosis',
      label: t('views.patient.clinical_diagnosis'),
      component: 'InputTextArea',
      colProps: {
        span: 12,
      },
    },
    {
      field: 'medication_history',
      label: t('views.patient.medication_history'),
      component: 'InputTextArea',
      colProps: {
        span: 12,
      },
    },
  ];
}

export function getFormProps(): FormProps {
  return {
    submitButtonOptions: {
      text: t('common.submitText'),
    },
    showResetButton: false,
    labelWidth: 100,
    schemas: getFormSchemas(),
    actionColOptions: {
      span: 24,
    },
  };
}
